﻿using Dos.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MallWeb.Controllers
{
    /// <summary>
    /// 公共Control处理类
    /// </summary>
    public class CommonController : Controller
    {
        // GET: Common
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult getImg()
        {
            #region 一些测试设置
            var config = new CaptchaControl();
            //背景是否动态
            config.IsBackgroundDynamic = true;
            //验证码是否动态
            config.IsForegroundDynamic = true;
            config.Height = 40;
            config.Width = 120;
            //设置字体
            config.Fonts = new List<CaptchaFontArrayItem>()
            {
                new CaptchaFontArrayItem(new Font("Broadway",1)),
                new CaptchaFontArrayItem(new Font("Cooper Black",1))
            };
            //背景颜色
            config.BackColor = Color.Bisque;
            #endregion

            var h = new Captcha();
            var imageStream = new MemoryStream();
            string str = h.GenerateCaptchaImage(imageStream);
            Session["checkCode"] = str;
            h.ProcessRequest();
            return View();
        }
    }
}